package cn.jetpiece.cloud.common.api.message;

import cn.jetpiece.cloud.common.api.message.model.result.AnnouncementMessageResult;
import cn.jetpiece.cloud.model.page.PageQuery;
import cn.jetpiece.cloud.model.page.PageResult;
import cn.jetpiece.cloud.model.response.Result;
import cn.jetpiece.cloud.common.api.message.model.params.CreateAnnouncementParam;
import cn.jetpiece.cloud.common.api.message.model.params.UpdateAnnouncementParam;
import cn.jetpiece.cloud.common.api.message.model.query.AnnouncementQuery;
import cn.jetpiece.cloud.common.api.message.model.result.AnnouncementResult;
import cn.jetpiece.cloud.resource.annotation.annotation.ApiResource;
import cn.jetpiece.cloud.resource.annotation.annotation.ScanResource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;

import javax.validation.Valid;
import java.util.Map;

/**
 * 系统通告表
 *
 * @author jetpiece
 * @since 2022-11-16
 */
@Api(tags="系统通告表")
@ApiResource(name="系统通告表")
public interface AnnouncementApi {

    String API = "/common/announcements";

    /**
     * 新增系统通告表
     *
     * @param param 新增参数
     * @return 返回结果
     */
    @ApiOperation(value = "新增系统通告表")
    @ScanResource(name = "新增系统通告表", path = API, method = RequestMethod.POST)
    Result<String> add(@RequestBody @Valid CreateAnnouncementParam param);

    /**
     * 修改系统通告表
     *
     * @param param 修改参数
     * @return 返回结果
     */
    @ApiOperation(value = "修改系统通告表")
    @ScanResource(name = "修改系统通告表", path = API, method = RequestMethod.PUT)
    Result<String> update(@RequestBody @Valid UpdateAnnouncementParam param);

    /**
     * 删除系统通告表
     *
     * @param id 主键
     * @return 返回结果
     */
    @ApiOperation(value = "删除系统通告表")
    @ScanResource(name = "删除系统通告表", path = API + "/{id}", method = RequestMethod.DELETE)
    Result<String> delete(@PathVariable(name = "id") Long id);

    /**
     * 批量删除系统通告表
     *
     * @param ids
     * @return 返回结果
     */
    @ApiOperation(value = "批量删除系统通告表")
    @ScanResource(name = "批量删除系统通告表", path = API+"/batch-del/{ids}", method = RequestMethod.DELETE)
    Result<String> deleteBatch(@PathVariable("ids") String ids);

    /**
     * 查询系统通告表信息
     *
     * @param id 主键
     * @return 返回结果
     */
    @ApiOperation(value = "查询系统通告表信息")
    @ScanResource(name = "查询系统通告表信息", path = API + "/{id}", method = RequestMethod.GET)
    Result<AnnouncementResult> get(@PathVariable(name = "id") Long id);

    /**
     * 查询系统通告表信息
     *
     * @param id 主键
     * @return 返回结果
     */
    @ApiOperation(value = "查询系统通告表信息")
    @ScanResource(name = "查询系统通告表信息", path = API + "/show/{id}", method = RequestMethod.GET)
    ModelAndView show(ModelAndView modelAndView,@PathVariable(name = "id") Long id);

    /**
     * 分页获取系统通告表
     *
     * @param query 查询条件
     * @return 返回结果
     */
    @ApiOperation(value = "分页获取系统通告表")
    @ScanResource(name = "分页获取系统通告表",path = API, method = RequestMethod.GET)
    Result<PageResult<AnnouncementResult>> page(@Valid @SpringQueryMap AnnouncementQuery query);

    /**
     * 分页获取系统通告表
     *
     * @param query 查询条件
     * @return 返回结果
     */
    @ApiOperation(value = "分页获取系统通告表")
    @ScanResource(name = "分页获取系统通告表",path = API + "/user-message", method = RequestMethod.GET)
    Result<PageResult<AnnouncementMessageResult>> customSelectPage(@Valid @SpringQueryMap AnnouncementQuery query);

    /**
     * 通过Excel导入系统通告表数据
     *
     * @return 返回结果
     */
    @ApiOperation(value = "通过Excel导入系统通告表数据")
    @ScanResource(name = "通过Excel导入系统通告表数据", path = API + "/import-excel", method = RequestMethod.POST)
    Result<String> importExcel(MultipartHttpServletRequest request);

    /**
     * 导出系统通告表数据到Excel
     *
     * @param query 查询条件
     * @return 返回结果
     */
    @ApiOperation(value = "通过excel导入系统通告表数据")
    @ScanResource(name = "通过excel导入系统通告表数据", path = API + "/export-excel", method = RequestMethod.GET)
    ModelAndView exportExcel(@Valid @SpringQueryMap AnnouncementQuery query);

    /**
     * 更新发布操作
     *
     * @param id 主键
     * @return 返回结果
     */
    @ApiOperation(value = "更新发布操作")
    @ScanResource(name = "更新发布操作", path = API + "/{id}/do-release-data", method = RequestMethod.PUT)
    Result<AnnouncementResult> doReleaseData(@PathVariable(name = "id") Long id);

    /**
     * 更新撤销操作
     *
     * @param id 主键
     * @return 返回结果
     */
    @ApiOperation(value = "更新发布操作")
    @ScanResource(name = "更新发布操作", path = API + "/{id}/do-revoke-data", method = RequestMethod.PUT)
    Result<AnnouncementResult> doRevokeData(@PathVariable(name = "id") Long id);


}
